package com.chushouya.order.constants;

import com.general.framework.core.enums.IEnum;

import java.util.Objects;

/**
 * 邮寄订单流程枚举
 * 流程: 0-20
 */
public enum CancelOrderProcessEnum implements IEnum<Integer> {

    NEW_ORDER(0, "下单成功", "订单提交成功"),
    CANCEL_ORDER(20, "订单取消", "订单已取消，感谢您的支持！");

    private Integer value;
    private String desc;
    private String statusText;

    CancelOrderProcessEnum(Integer value, String desc, String statusText) {
        this.value = value;
        this.desc = desc;
        this.statusText = statusText;
    }

    public static String getDesc(Integer status) {
        for (CancelOrderProcessEnum thisEnum : CancelOrderProcessEnum.values()) {
            if (Objects.equals(thisEnum.value, status)) {
                return thisEnum.desc;
            }
        }
        return CancelOrderProcessEnum.NEW_ORDER.desc;
    }

    public static CancelOrderProcessEnum get(Integer status) {
        for (CancelOrderProcessEnum thisEnum : CancelOrderProcessEnum.values()) {
            if (Objects.equals(thisEnum.value, status)) {
                return thisEnum;
            }
        }
        return CancelOrderProcessEnum.NEW_ORDER;
    }

    /**
     * 获取下一个状态
     */
    public CancelOrderProcessEnum getNext() {
        switch (this) {
            case NEW_ORDER:
                return CANCEL_ORDER;
            case CANCEL_ORDER:
                return CANCEL_ORDER;
            default:
                return this;
        }
    }

    @Override
    public Integer value() {
        return this.value;
    }

    @Override
    public String named() {
        return this.desc;
    }

    public String getDesc() {
        return desc;
    }

    public String getStatusText() {
        return statusText;
    }
}
